<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// 公开访问
Route::post('config/global', 'Api\CommonController@config')->name('config.global');//全局配置
Route::post('common/home', 'Api\ContentController@home')->name('common.home');//首页信息
Route::post('quotation', 'Api\QuotationController@index')->name('quotation.home');//首页信息
Route::post('content/lists', 'Api\ContentController@lists')->name('content.lists');//内容列表


Route::prefix("user")
    ->name("user.")
    ->group(function () {
        Route::post('register', 'Api\UserController@register')->name('register');//注册
        Route::post('login', 'Api\UserController@login')->name('login');//登陆
        Route::post('resetPwd', 'Api\UserController@resetPwd')->name('resetPwd');//忘记密码
        Route::post('requestCode', 'Api\CommonController@requestCode')->name('requestCode');//发送验证码
    });


Route::prefix("test")
    ->name("test.")
    ->group(function () {
        Route::get("hello", function () {
            return "world";
        })->name("hello");

        Route::get("greeting", function () {
            return "Greeting <br/>" . \route("test.hello");
        });
    });


// ***************************************
// *************** 需要登录 ***************
// ***************************************
Route::group(['middleware' => ['token.bearer']], function () {
    // 用户相关
    Route::prefix("user")
        ->name("user.")
        ->group(function () {
            Route::post('getUser', 'Api\UserController@getUser')->name('getUser');   //获取用户
            Route::post('updatePwd', 'Api\UserController@updatePwd')->name('updatePwd');//修改密码
            Route::post('updatePayPwd', 'Api\UserController@updatePayPwd')->name('updatePayPwd');//修改支付密码
            Route::post('resetPayPwd', 'Api\UserController@resetPayPwd')->name('resetPayPwd');//忘记支付密码

            Route::post('profile', 'Api\UserController@profile')->name('profile');//用户中心
            Route::post('verification', 'Api\VerificationController@index')->name('verification.index');//实名信息
            Route::post('verification/request', 'Api\VerificationController@request')->name('verification.request');//提交实名

            // TODO
            Route::post('logout', 'Api\UserController@logout')->name('logout');//注销
        });

    //充值
    Route::prefix("deposit")
        ->name("deposit.")
        ->group(function () {
            Route::post('deposit', 'Api\DepositController@deposit')->name('process');

            Route::post('capture', 'Api\DepositController@capture')->name('capture'); // 向充值订单提交已上传截图地址
            Route::post('history', 'Api\DepositController@history')->name('history'); // 充值历史
            Route::post('method', 'Api\DepositController@method')->name('method'); // 充值方法
            Route::post('prepare', 'Api\DepositController@prepare')->name('prepare'); // 充值前置
            Route::post('detail', 'Api\DepositController@detail')->name('detail'); // 充值详情
        });

    //提现
    Route::prefix("withdraw")
        ->name("withdraw.")
        ->group(function () {
            Route::post('withdraw', 'Api\WithdrawController@withdraw')->name('process');

            Route::post('history', 'Api\WithdrawController@history')->name('history'); // 提现历史
            Route::post('prepare', 'Api\WithdrawController@prepare')->name('prepare'); // 提现前置
        });


    Route::prefix("common")
        ->name("common.")
        ->group(function () {
            Route::post('/upload', 'Api\CommonController@actionUpload')->name('upload');//上传图片
        });

    Route::prefix("notification")
        ->name("notification.")
        ->group(function () {
            Route::post('lists', 'Api\NotificationController@lists')->name('lists');//消息列表
            Route::post('detail', 'Api\NotificationController@detail')->name('detail');//消息详情
        });
});
